<template>
  <view>
    <uni-popup ref="Hselect">
      <view
        style="
          height: 600rpx;
          width: 750rpx;
          border-radius: 20rpx 20rpx 0rpx 0rpx;
          background-color: white;
        "
      >
        <view
          style="
            width: 100%;
            display: flex;
            justify-content: space-between;
            height: 80rpx;
            align-items: center;
          "
        >
          <view style="margin-left: 30rpx" @click="close">取消</view>
          <view style="margin-right: 30rpx" @click="checkOk">确定</view>
        </view>
        <scroll-view scroll-y style="height: 520rpx">
          <view
            style="
              width: 100%;
              height: 60rpx;
              display: flex;
              justify-content: space-between;
              align-items: center;
              border-bottom: 1px solid #aaaaaa65;
            "
            v-for="(item, index) in list"
            @click="checkDatas(index)"
            :key="index"
          >
            <view style="margin-left: 30rpx"
              ><text>{{ item[subscript] }}</text></view
            >
            <uni-icons
              type="checkmarkempty"
              size="30"
              v-show="index == checkIndex"
              style="margin-right: 30rpx"
            ></uni-icons>
          </view>
        </scroll-view>
      </view>
    </uni-popup>
  </view>
</template>

<script>
export default {
  name: "h-select",
  props: {
    list: {
      type: Array,
      default: [],
    },
    subscript: {
      type: String,
      default: "name",
    },
    check: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      checkData: {},
      checkIndex: 1000000000000,
    };
  },
  created() {},
  methods: {
    open() {
      this.$refs.Hselect.open("bottom");
    },
    checkDatas(e) {
      this.checkData = this.list[e];
      this.checkIndex = e;
    },
    checkOk() {
      this.$emit("change", this.checkData);
      this.close();
    },
    close() {
      this.$refs.Hselect.close();
    },
  },
};
</script>

<style scoped lang="less"></style>
